home *** CD-ROM | disk | FTP | other *** search
/ AppleScript - The Beta Release / AppleScript - The Beta Release.iso / Documentation / develop / Better Apple Event Coding / Code Samples / TESample.h < prev    next >
Encoding:
C/C++ Source or Header  |  1992-10-16  |  2.6 KB  |  89 lines  |  [TEXT/MPS ]

  1. /*------------------------------------------------------------------------------------------
  2.  
  3.     Program:    CPlusTESample 2.0
  4.     File:        TESample.h
  5.     Uses:       Application.h
  6.                 TECommon.h
  7.  
  8.     by Andrew Shebanow
  9.     of Apple Macintosh Developer Technical Support
  10.     with modifications by Eric Berdahl
  11.  
  12.     Copyright © 1989-1990 Apple Computer, Inc.
  13.     Copyright © 1992 Eric Berdahl
  14.     All rights reserved.
  15.  
  16. ------------------------------------------------------------------------------------------*/
  17.  
  18. #ifndef __TESAMPLE__
  19. #define __TESAMPLE__
  20.  
  21. // we need resource definitions
  22. #ifndef __TECOMMON__
  23. #include "TECommon.h"
  24. #endif
  25.  
  26. // Since we are based on the Application class, we need its class definitions
  27. #ifndef __APPLICATION__
  28. #include "Application.h"
  29. #endif
  30.  
  31. // we need object model support
  32. #ifndef __UAPPLEOBJECT__
  33. #include "UAppleObject.h"
  34. #endif
  35.  
  36.  
  37. // TESample is our application class. It is a subclass of TApplication,
  38. // so it only needs to specify its behaviour in areas where it is different
  39. // from the default.
  40. class TESample : public TApplication, public MAppleObject {
  41. public:
  42.             TESample();                // Our constructor
  43.  
  44.     static TESample*    GetTEApplication();
  45.  
  46.     // the actual methods referenced via AppleEvents
  47.     virtual void DoFinderNew(const AppleEvent& message, AppleEvent& reply);
  48.     virtual void DoFinderOpen(const AppleEvent& message, AppleEvent& reply);
  49.     virtual void DoFinderPrint(const AppleEvent& message, AppleEvent& reply);
  50.     virtual void DoFinderQuit(const AppleEvent& message, AppleEvent& reply);
  51.     virtual void DoAppleNewElement(const AppleEvent& message, AppleEvent& reply);
  52.  
  53.     // more details for Object Model support
  54.     virtual MAppleObject* GetWindowObject(DescType keyForm, const AEDesc& keyData);
  55.  
  56.     // Object Model support
  57.     virtual DescType GetAppleClass() const;
  58.     virtual long CountContainedObjects(DescType ofType);
  59.     virtual void DoAppleEvent(const AppleEvent& message,
  60.                               AppleEvent& reply,
  61.                               long refCon);
  62.     virtual MAppleObject* GetContainedObject(DescType desiredType,
  63.                                              DescType keyForm,
  64.                                              const AEDesc& keyData,
  65.                                              Boolean& needDisposal);
  66.     virtual Boolean CompareAppleObjects(DescType operation,
  67.                                         const MAppleObject& toWhat);
  68.  
  69. private:
  70.     // routines from TApplication we are overriding
  71.     long    HeapNeeded();
  72.     unsigned long SleepVal();
  73.     void    DoIdle();
  74.     void    AdjustCursor();
  75.     void    AdjustMenus();
  76.     void    DoMenuCommand(short menuID, short menuItem);
  77.     void    OpenADoc(short vRefNum, long dirID, StringPtr fName, OSType fType);
  78.  
  79.     // routines for our own devious purposes
  80.     void    DoNew();
  81.     void    DoOpen();    
  82. };
  83.  
  84.  
  85. WindowPtr GetWindowFromName(Str255 name);
  86. WindowPtr GetWindowFromIndex(short index);
  87.  
  88. #endif
  89.